package com.ruoyi.deeplearn.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.deeplearn.domain.DeepTrainValidation;
import com.ruoyi.deeplearn.service.IDeepTrainValidationService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 训练验证数据集Controller
 *
 * @author rww
 * @date 2022-12-10
 */
@RestController
@RequestMapping("/deeplearn/validation")
public class DeepTrainValidationController extends BaseController
{
    @Autowired
    private IDeepTrainValidationService deepTrainValidationService;

    /**
     * 查询训练验证数据集列表
     */
//    @PreAuthorize("@ss.hasPermi('deeplearn:validation:list')")
    @GetMapping("/list")
    public TableDataInfo list(DeepTrainValidation deepTrainValidation)
    {
        startPage();
        List<DeepTrainValidation> list = deepTrainValidationService.selectDeepTrainValidationList(deepTrainValidation);
        return getDataTable(list);
    }

    /**
     * 导出训练验证数据集列表
     */
//    @PreAuthorize("@ss.hasPermi('deeplearn:validation:export')")
    @Log(title = "训练验证数据集", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DeepTrainValidation deepTrainValidation)
    {
        List<DeepTrainValidation> list = deepTrainValidationService.selectDeepTrainValidationList(deepTrainValidation);
        ExcelUtil<DeepTrainValidation> util = new ExcelUtil<DeepTrainValidation>(DeepTrainValidation.class);
        util.exportExcel(response, list, "训练验证数据集数据");
    }

    /**
     * 获取训练验证数据集详细信息
     */
//    @PreAuthorize("@ss.hasPermi('deeplearn:validation:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(deepTrainValidationService.selectDeepTrainValidationById(id));
    }

    /**
     * 新增训练验证数据集
     */
//    @PreAuthorize("@ss.hasPermi('deeplearn:validation:add')")
    @Log(title = "训练验证数据集", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DeepTrainValidation deepTrainValidation)
    {
        return toAjax(deepTrainValidationService.insertDeepTrainValidation(deepTrainValidation));
    }

    /**
     * 修改训练验证数据集
     */
//    @PreAuthorize("@ss.hasPermi('deeplearn:validation:edit')")
    @Log(title = "训练验证数据集", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DeepTrainValidation deepTrainValidation)
    {
        return toAjax(deepTrainValidationService.updateDeepTrainValidation(deepTrainValidation));
    }

    /**
     * 删除训练验证数据集
     */
//    @PreAuthorize("@ss.hasPermi('deeplearn:validation:remove')")
    @Log(title = "训练验证数据集", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(deepTrainValidationService.deleteDeepTrainValidationByIds(ids));
    }
}
